package com.ostrich.a2104shopping.aspectj;

import android.util.Log;

import com.alibaba.android.arouter.launcher.ARouter;
import com.blankj.utilcode.util.SPUtils;

import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;

/**
 * @Author : yaotianxue
 * @Time : On 2023/9/26 09:15
 * @Description : LoginCheckAspectj
 */
@Aspect
public class LoginCheckAspectj {
    //切面点
    @Pointcut("execution(@com.ostrich.a2104shopping.aspectj.LoginCheck * *(..))")
    public void loginCheck222(){
        Log.d("ytx", "loginCheck222: ");
    }
    //处理逻辑
    @Around("loginCheck222()")
    public void aroundLoginCheck(ProceedingJoinPoint point) throws Throwable {
        Log.d("ytx", "aroundLoginCheck: ");
        boolean login = SPUtils.getInstance().getBoolean("login");
        if(login){
            Log.d("ytx", "登陆过: ");
            point.proceed();//登陆过：继续执行后续操作
        }else{
            //没登陆：跳转到登陆页面
            Log.d("ytx", "没登陆过: ");
            ARouter.getInstance().build("/user/LoginActivity").navigation();

        }
    }
}
